import Login from '@/pages/login/index'
import Home from '@/pages/home/index'
import App from '@/App'
import User from '@/pages/user'
import { createHashRouter, Navigate } from 'react-router-dom'
import {
  ContainerOutlined,
  FileOutlined,
  FundViewOutlined,
  PieChartOutlined,
  SettingOutlined,
  UserOutlined,
} from '@ant-design/icons'
import { lazy, Suspense } from 'react'

const Bank = lazy(() => import('@/pages/bank/index'))
const BankQuestion = lazy(() => import('@/pages/bank/question/index'))
const BankTags = lazy(() => import('@/pages/bank/tag/index'))
const QuesType = lazy(() => import('@/pages/bank/quesType/index'))
const ExamPaper = lazy(() => import('@/pages/examPaper/index'))
const ExamPaperList = lazy(
  () => import('@/pages/examPaper/examPaperList/index')
)
const AddExamPaper = lazy(() => import('@/pages/examPaper/addExamPaper/index'))
const Meeting = lazy(() => import('@/pages/meeting/index'))
const MeetingList = lazy(() => import('@/pages/meeting/meetingList/index'))
const MeetingConf = lazy(() => import('@/pages/meeting/meetingConf/index'))
const Exam = lazy(() => import('@/pages/exam/index'))
const ExamList = lazy(() => import('@/pages/exam/examList/index'))
const ExamConf = lazy(() => import('@/pages/exam/examConf/index'))
const Setting = lazy(() => import('@/pages/setting/index'))
const LegalDocx = lazy(() => import('@/pages/setting/legalDocx/index'))
const DashBoard = lazy(() => import('@/pages/dashBoard/index'))
export const managementMenu = [
  // {
  //   id: 'dashboard',
  //   path: 'dashboard',
  //   element: <DashBoard></DashBoard>,
  //   handle: {
  //     name: '数据板',
  //     icon: <PieChartOutlined />,
  //   },
  // },
  // {
  //   id: 'bank',
  //   path: 'bank',
  //   element: (
  //     <Suspense fallback={<div>加载中...</div>}>
  //       <Bank />
  //     </Suspense>
  //   ),
  //   handle: {
  //     name: '题库',
  //     icon: <FileOutlined />,
  //   },
  //   children: [
  //     {
  //       id: 'question',
  //       path: 'question',
  //       element: (
  //         <Suspense fallback={<div>加载中...</div>}>
  //           <BankQuestion />
  //         </Suspense>
  //       ),
  //       handle: {
  //         name: '题目管理',
  //         icon: <FileOutlined />,
  //       },
  //     },
  //     {
  //       id: 'type',
  //       path: 'type',
  //       element: (
  //         <Suspense fallback={<div>加载中...</div>}>
  //           <QuesType />
  //         </Suspense>
  //       ),
  //       handle: {
  //         name: '题型管理',
  //         icon: <FileOutlined />,
  //       },
  //     },
  //     {
  //       id: 'tag',
  //       path: 'tag',
  //       element: (
  //         <Suspense fallback={<div>加载中...</div>}>
  //           <BankTags />
  //         </Suspense>
  //       ),
  //       handle: {
  //         name: '标签管理',
  //         icon: <FileOutlined />,
  //       },
  //     },
  //   ],
  // },
  // {
  //   id: 'exampaper',
  //   path: 'exampaper',
  //   element: (
  //     <Suspense fallback={<div>加载中...</div>}>
  //       <ExamPaper />
  //     </Suspense>
  //   ),
  //   handle: {
  //     name: '试卷库',
  //     icon: <ContainerOutlined />,
  //   },
  //   children: [
  //     {
  //       id: 'examPaperList',
  //       path: 'list',
  //       element: (
  //         <Suspense fallback={<div>加载中...</div>}>
  //           <ExamPaperList />
  //         </Suspense>
  //       ),
  //       handle: {
  //         name: '试卷列表',
  //         icon: <FileOutlined />,
  //       },
  //     },
  //     {
  //       id: 'examPaperAdd',
  //       path: 'add',
  //       element: (
  //         <Suspense fallback={<div>加载中...</div>}>
  //           <AddExamPaper />
  //         </Suspense>
  //       ),
  //       handle: {
  //         name: '添加试卷',
  //         icon: <FileOutlined />,
  //       },
  //     },
  //     {
  //       id: 'examPaperShow',
  //       path: 'show/:id',
  //       element: (
  //         <Suspense fallback={<div>加载中...</div>}>
  //           <AddExamPaper />
  //         </Suspense>
  //       ),
  //       handle: {
  //         name: '编辑试卷',
  //         icon: <FileOutlined />,
  //         noShow: true,
  //       },
  //     },
  //   ],
  // },
  {
    id: 'meeting',
    path: 'meeting',
    element: (
      <Suspense fallback={<div>加载中...</div>}>
        <Meeting />
      </Suspense>
    ),
    handle: {
      name: '面试管理',
      icon: <ContainerOutlined />,
    },
    children: [
      {
        id: 'meetingList',
        path: 'list',
        element: (
          <Suspense fallback={<div>加载中...</div>}>
            <MeetingList />
          </Suspense>
        ),
        handle: {
          name: '面试列表',
          icon: <FileOutlined />,
        },
      },
      {
        id: 'meetingConf',
        path: 'conf/:id',
        element: (
          <Suspense fallback={<div>加载中...</div>}>
            <MeetingConf />
          </Suspense>
        ),
        handle: {
          name: '配置面试',
          icon: <FileOutlined />,
          noShow: true,
        },
      },
    ],
  },
  // {
  //   id: 'exam',
  //   path: 'exam',
  //   element: (
  //     <Suspense fallback={<div>加载中...</div>}>
  //       <Exam />
  //     </Suspense>
  //   ),
  //   handle: {
  //     name: '笔试管理',
  //     icon: <FundViewOutlined />,
  //   },
  //   children: [
  //     {
  //       id: 'examList',
  //       path: 'list',
  //       element: (
  //         <Suspense fallback={<div>加载中...</div>}>
  //           <ExamList />
  //         </Suspense>
  //       ),
  //       handle: {
  //         name: '笔试列表',
  //         icon: <FileOutlined />,
  //       },
  //     },
  //     {
  //       id: 'examConf',
  //       path: 'conf/:id',
  //       element: (
  //         <Suspense fallback={<div>加载中...</div>}>
  //           <ExamConf />
  //         </Suspense>
  //       ),
  //       handle: {
  //         name: '配置笔试',
  //         icon: <FileOutlined />,
  //         noShow: true,
  //       },
  //     },
  //   ],
  // },
  {
    id: 'user',
    path: 'user',
    element: <User></User>,
    handle: {
      name: '用户库',
      icon: <UserOutlined />,
    },
  },
  {
    id: 'setting',
    path: 'setting',
    element: (
      <Suspense fallback={<div>加载中...</div>}>
        <Setting />
      </Suspense>
    ),
    handle: {
      name: '设置',
      icon: <SettingOutlined />,
    },
    children: [
      {
        id: 'docx',
        path: 'docx',
        element: (
          <Suspense fallback={<div>加载中...</div>}>
            <LegalDocx />
          </Suspense>
        ),
        handle: {
          name: '法务文档',
          icon: <SettingOutlined />,
        },
      },
    ],
  },
]

const router = createHashRouter([
  {
    path: '/',
    element: <App></App>,
    children: [
      {
        path: 'home',
        element: <Home></Home>,
        handle: {
          name: '主页',
        },
        children: [
          {
            index: true,
            element: <Navigate to={managementMenu[0].path} replace />,
          },
          ...managementMenu,
        ],
      },
      {
        path: 'login',
        element: <Login></Login>,
        handle: {
          name: '登录',
        },
      },
    ],
  },
])

export default router
